const KoaRouter = require('koa-router');

const productInformationRouter = new KoaRouter({prefix: '/products'});

const {
  uploadProductInformation,
} = require('../middleware/file.middleware');

const {
  getProductInformationByName,
  getProductInformationByLimit,
  addProductInformation,
  changeProductInformation,
  deleteProductInformation
} = require('../controller/products.controller');

// 通过名称获取商品信息
productInformationRouter.get('/getProductInformationByName', getProductInformationByName);

// 获取商品信息
productInformationRouter.get('/getProductInformationByLimit', getProductInformationByLimit);

// 上传图片及信息
productInformationRouter.post('/uploadProductInformation', uploadProductInformation, addProductInformation);

// 修改商品信息
productInformationRouter.get('/changeProductInformation', changeProductInformation);

// 删除商品信息
productInformationRouter.delete('/deleteProductInformation', deleteProductInformation);

module.exports = productInformationRouter;